﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;

namespace BUS
{
    public class LoaiDaiLyBUS
    {
        #region 1.Retrieving
        public static List<LoaiDaiLyDTO> SellectLoaiDaiLyAll()
        {
            return LoaiDaiLyDAO.SelectLoaiDaiLyAll();
        }

        public static bool CheckIDLoaiDaiLyDTO(string maLoaiDaiLy)
        {
            bool isExits = false;
            if (LoaiDaiLyDAO.SellectLoaiDaiLyByID(maLoaiDaiLy).Count == 1)
            {
                isExits = true;
            }
            return isExits;
        }
        public static List<LoaiDaiLyDTO> selectLoaiDaiLyByID(string ID)
        {
            return LoaiDaiLyDAO.SellectLoaiDaiLyByID(ID);
        }


        #endregion
        #region 2.Updating
        public static bool UpdateLoaiDaiLy(LoaiDaiLyDTO loaiDaiLy)
        {
            if (!LoaiDaiLyBUS.CheckIDLoaiDaiLyDTO(loaiDaiLy.MaLoaiDaiLy))
            {
                return false;
            }
            return LoaiDaiLyDAO.UpdateLoaiDaiLy(loaiDaiLy);
        }
        #endregion
        #region 3.Deleting
        public static bool DeleteLoaiDaiLy(string maLoai)
        {
            if (!LoaiDaiLyBUS.CheckIDLoaiDaiLyDTO(maLoai))
            {
                return false;
            }
            return LoaiDaiLyDAO.DeleteLoaiDaiLy(maLoai);
        }
        #endregion
        #region 4.Inserting
        public static bool InsertLoaiDaiLy(LoaiDaiLyDTO loaiDaiLy)
        {
            if (LoaiDaiLyBUS.CheckIDLoaiDaiLyDTO(loaiDaiLy.MaLoaiDaiLy))
            {
                return false;
            }
            return LoaiDaiLyDAO.InsertLoaiDaiLy(loaiDaiLy);
        }
        #endregion
    }
}
